
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Random;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Valdigleis
 */
public class SaveVectors {
    
     public void CreateSaveVector(int [] vet, File file){
        try{
            BufferedWriter buffer = new BufferedWriter(new FileWriter (file));
            Random random = new Random();
            for(int i = 0; i < vet.length; i++){
                buffer.write(vet[i]+" ");
                buffer.newLine();
            }
            buffer.close();
            System.out.println("Arquivo gravado");
        }catch (IOException e){
            System.out.println("Erro no arquivo");
        }
        
    }
     
     public int[] getVector(File file){
         String linha;
         int vetor[] = new int[10000];
         try{
            BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
            int i = 0;
             while (br.ready()){
                 linha = br.readLine().trim();
                 vetor[i] = Integer.parseInt(linha);
                 i++;
             }
             br.close();
             return vetor;
        }catch (IOException e){
            System.out.println("Erro no arquivo");
        }
        return vetor;
     }
}
